﻿using System;
using System.Web.Mvc;
using Domain;
using Supermodel.Controllers;
using Supermodel.MVC;
using Supermodel.Repository;

namespace WebUI.Controllers
{
    public class UsersController : CRUDControllerBase<User, UserFormModel, MyUnitOfWork>
    {
        [HttpPost]
        public ActionResult Disable(long id, HttpPost ignore)
        {
            using (new MyUnitOfWork())
            {
                var entityItem = RepoFactory.Create<User>().GetById(id);
                entityItem.Disable();
                return RedirectToAction("Edit", new { id });
            }
        }

        public override ActionResult Edit(long id, HttpDelete ignore)
        {
            throw new InvalidOperationException();
        }
    }
}
